<?php
mysqli_connect('localhost', 'root', 'root','student');
class Mysql{
	public $mysql_localhost;
	public $mysql_id;
	public $mysql_pasd;
	public $mysql_database;
	public function __construct($localhost,$id,$pasd,$database){
		$this->mysql_localhost=$localhost;
		$this->mysql_id=$id;
		$this->mysql_pasd=$pasd;
		$this->mysql_database=$database;
	}
	public function connect(){
		$localhost=$this->mysql_localhost;
		$id=$this->mysql_id;
		$pasd=$this->mysql_pasd;
		$database=$this->mysql_database;
		$this->connect=mysqli_connect($localhost, $id, $pasd,$database) or die(mysqli_error($link));
		mysqli_set_charset($this->connect, 'utf-8');
		return $this->connect;
		echo '数据库连接成功';
	}
}



$mysql1=new Mysql('localhost', 'root', 'root','student');
$link=$mysql1->connect();
$sql="select * from info";
$re=mysqli_query($link, $sql);
$data=mysqli_fetch_all($re);
print_r($data);
?>